package com.lhb.test.rabbitmqTest;

import com.lhb.test.config.Pkg;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PublishDemo {

    @Autowired
    private AmqpTemplate amqpTemplate;

    public String publish2mq(String msg){

        String name = "hello world"+msg;
        System.out.println(name);
        amqpTemplate.convertAndSend(Pkg.exchange,Pkg.routing,name);
        return name;
    }
}
